package com.mawendaxiong.blogprovider.blogType.controller;


import com.mawendaxiong.blogprovider.blogType.entity.BlogType;
import com.mawendaxiong.blogprovider.blogType.service.BlogTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.UUID;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mawendaxiong
 * @since 2020-06-23
 */
@RestController
@RequestMapping("/blogType")
@Slf4j
public class BlogTypeController {
    @Autowired
    private BlogTypeService service;

    @GetMapping("getAllType")
    public List<BlogType> getAllType() {
        System.out.println("123");
        return service.getAllType();
    }


    @GetMapping("getFakeAllType")
    public List<BlogType> getFakeAllType(@RequestParam String s) {
        System.out.println(s);
        List<BlogType> fake = new LinkedList<>();
        String[] names = new String[]{"springboot", "duboo", "redis", "vue", "springcloude", "mysql", "linux",
                "python", "mybatis", "nacos"};
        for (int i = 0; i < 10; i++) {
            Random random = new Random(System.currentTimeMillis());
            BlogType blogType = new BlogType();
            blogType.setKid(UUID.randomUUID().toString().replace("-", ""));
            blogType.setBlogSize(random.nextInt(50));
            blogType.setName(names[i]);
            fake.add(blogType);
        }
        return fake;
    }
}
